var q6 = "#fUI/RunnerGame.img/RunnerGameUI/UI/Point/1#"
	var q1 = "#fUI/SoulUI.img/DungeonMap/icon/dungeonItem/0#"
	var h1 = "#fUI/Login.img/WorldNotice/1/5#"
	var h4 = "#fUI/Gateway.img/WorldSelect/BtDot/normal/0#"
	var h6 = "#fUI/SoulUI.img/DungeonEffect/2350012/15#"
	var h7 = "#fItem/Cash/0501.img/05010000/effect/default/0#"
	var h8 = "#fItem/Cash/0583.img/05830002/info/icon#"
	var h9 = "#fItem/Consume/0237.img/02370000/info/icon#"
	var bbb1 = "#fItem/Cash/0516.img/05160005/info/icon#"
	var bbb2 = "#fItem/Cash/0516.img/05160000/info/icon#"
	var bbb3 = "#fItem/Cash/0516.img/05160001/info/icon#"
	var ddd1 = "#fItem/Cash/0523.img/05230000/info/icon#"
	var ddd3 = "#fItem/Cash/0533.img/05330000/info/icon#"
	var ddd4 = "#fItem/Cash/0537.img/05370000/info/icon#"
	var ddd5 = "#fItem/Cash/0548.img/05480000/info/icon#"
	var ddd6 = "#fItem/Cash/0548.img/05480001/info/icon#"
	var h7 = "#fItem/Cash/0501.img/05010000/effect/default/0#"
	var s18 = "#fUI/UIWindow/AriantMatch/characterIcon/5#";
var aaa = "#fUI/UIWindow/AriantMatch/characterIcon/5#";
var yun = "#fUI/UIWindow/Quest/icon8/0#"; ////红沙漏
var yun2 = "#fUI/UIWindow/Quest/icon8/0#"; ////蓝指标
var yun8 = "#fUI/UIWindow/MonsterBook/arrowLeft/normal/0#"; ////金左指标
var yun9 = "#fUI/UIWindow/MonsterBook/arrowRight/normal/0#"; ////金右指标
var ttt = "#fUI/UIWindow/Quest/icon2/7#"; //"+ttt+"//美化1
var ttt2 = "#fUI/UIWindow/Quest/icon6/7#"; ////美化2
var ttt3 = "#fUI/UIWindow/Quest/icon3/6#"; //"+ttt3+"//美化圆
var ttt4 = "#fUI/UIWindow/Quest/icon5/1#"; //"+ttt4+"//美化New
var ttt5 = "#fUI/UIWindow/Quest/icon0#"; ////美化!
var ttt7 = "#fUI/Basic/BtHide3/mouseOver/0#"; //"+ttt6+"//美化会员
var ttt6 = "#fUI/UIWindow.img/PvP/Scroll/enabled/next2#";
var epp = "#fEffect/CharacterEff/1082312/0/0#"; //彩光
var eff = "#fCharacter/Weapon/01702523.img/48/straight/0/effect#"; //彩虹带
var eff = "#fEffect/CharacterEff/1112905/0/1#"; //
var epp = "#fEffect/CharacterEff/1082312/0/0#"; //彩光
var epp1 = "#fEffect/CharacterEff/1082312/2/0#"; //彩光1
var axx = "#fEffect/CharacterEff/1051294/0/0#"; //爱心
var xxx = "#fEffect/CharacterEff/1082565/2/0#"; //星系
var ppp = "#fEffect/CharacterEff/1112907/4/0#"; //泡炮
var epp3 = "#fEffect/CharacterEff/1112908/0/1#"; //彩光3
var axx1 = "#fEffect/CharacterEff/1062114/1/0#"; //爱心
var zs = "#fEffect/CharacterEff/1112946/2/0#"; //砖石粉
var zs1 = "#fEffect/CharacterEff/1112946/1/1#"; //砖石蓝
var dxxx = "#fEffect/CharacterEff/1102232/2/0#"; //星系
var tz = "#fEffect/CharacterEff/1082565/2/0#"; //兔子蓝
var tz1 = "#fEffect/CharacterEff/1082565/4/0#"; //兔子粉
var tz7 = "#fEffect/CharacterEff/1112900/3/1#"; //音符红
var tz8 = "#fEffect/CharacterEff/1112900/4/1#"; //音符绿
var tz88 = "#fEffect/CharacterEff/1112900/5/1#"; //音符绿!
var yun1 = "#fUI/UIWindow/Quest/icon7/10#"; ////红色圆
var tz9 = "#fEffect/CharacterEff/1112902/0/0#"; //蓝心
var tz10 = "#fEffect/CharacterEff/1112903/0/0#"; //红心
var tz11 = "#fEffect/CharacterEff/1112904/0/0#"; //彩心
var tz12 = "#fEffect/CharacterEff/1112924/0/0#"; //黄星
var tz13 = "#fEffect/CharacterEff/1112925/0/0#"; //蓝星
var tz14 = "#fEffect/CharacterEff/1112926/0/0#"; //红星
var tz15 = "#fEffect/CharacterEff/1112949/0/0#"; //花样音符
var tz16 = "#fEffect/CharacterEff/1112949/1/0#"; //花样音符
var tz17 = "#fEffect/CharacterEff/1112949/2/0#"; //花样音符
var tz18 = "#fEffect/CharacterEff/1112949/3/0#"; //花样音符
var tz19 = "#fEffect/CharacterEff/1112949/4/0#"; //花样音符
var tz20 = "#fEffect/CharacterEff/1114000/1/0#"; //红星花
var head = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n";
var yun4 = "#fUI/UIWindow/Quest/reward#"; ////奖励
var 戴米安 = "#fMob/8880130.img/stand/0#";
var 闹钟 = "#fMob/8500001.img/stand/0#";
var 希纳斯 = "#fMob/8850011.img/stand/0#";
var 扎昆 = "#fMob/8800000.img/stand/0#";
var 奖励 = "#fUI/UIWindow/Quest/reward#";
var 黑水晶 = "#v4251402#";
var 五彩水晶 = "#v4251202#";
var ss1 = "#v4250802#";
var ss2 = "#v4251102#";
var ss3 = "#v4250902#";
var ss4 = "#v4251002#";
var 黄金 = "#v4011006#";
var 青铜 = "#v4011000#";
var 钢铁 = "#v4011001#";
var 祖母绿 = "#v4250002#";
var 祖母 = "#v4250702#";
var 海蓝 = "#v4250502#";
var 石榴 = "#v4250202#";
var 蛋白 = "#v4250302#";
function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			var text = "#n#r  尊敬的" + cm.getServerName() + "玩家您当前可查看的内容有：\r\n  ps:#k排行榜更新周期为7天，7日更新制！ 本周上榜的玩家可\r\n  以领取一次奖励哟！新一周的奖励是不补发的哦！#l\r\n";
			//text += "#b#L0#" + tz14 + "#e#rPPMS好友#b排行榜  ";
			//text += "#b#L2#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			//text += "#b#L1#" + tz13 + "#e#r勤奋制作#b排行榜  #l";
			//text += "#b#L2#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			text += "#b#L3#" + tz14 + "#r" + cm.getServerName() + "土豪#b排行榜  #l";
			text += "#b#L4#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			text += "#b#L5#" + tz13 + "#r" + cm.getServerName() + "乱斗#b排行榜  #l";
			text += "#b#L6#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			text += "#b#L7#" + tz14 + "#r" + cm.getServerName() + "人气#b排行榜  #l";
			text += "#b#L8#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			text += "#b#L9#" + tz13 + "#r" + cm.getServerName() + "家族#b排行榜  #l";//家族的这个有自己的UI
			text += "#b#L10#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			text += "#b#L11#" + tz14 + "#r" + cm.getServerName() + "在线#b排行榜  #l";
			text += "#b#L12#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			text += "#b#L13#" + tz14 + "#r" + cm.getServerName() + "道场#b排行榜  #l";//道场这个有自己的UI
			text += "#b#L14#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			//text += "#b#L13#" + tz13 + "#r武陵道场#b排行榜  #l";
			//text += "#b#L14#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			//text += "#b#L15#" + tz14 + "#r飞龙在天#b排行榜  #l";
			//text += "#b#L16#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			//text += "#b#L17#" + tz13 + "#r枫叶高校#b排行榜  #l";
			//text += "#b#L18#" + "#d<我上榜了,我要领取奖励>#l\r\n";
			cm.sendSimple(text);
		} else if (status == 1) {
			switch (selection) {
			case 0:
				cm.dispose();
				cm.openNpc(9130115, "黑水晶列表"); //土豪赞助前10名排行榜 按玩家充值的点卷排名
				break;
			case 6://乱斗奖励
				var conn = cm.getConnection();
				var sql = "select name, pvpnx from characters where gm<=0 order by pvpnx desc limit 10;";
				var pstmt = conn.prepareStatement(sql);
				var result = pstmt.executeQuery();
				result.next();
				var name = result.getString("name");
				if (cm.getChar().getName() == name) {
					if (cm.getDaysPQLog("PK王", 7) == 0) {
						cm.setPQLog("PK王", 1);
						cm.gainItem(4310015, 30);
						cm.gainItem(4250802, 12);	
						cm.gainItem(4251102, 12);	
						cm.gainItem(4251002, 12);	
						cm.gainItem(4250902, 12);
						cm.gainItem(4250902, 12);						
						cm.gainNX(1,50000);			
				        cm.gainPartyEnergy(1200);//不知道为啥加入这个积分的代码就报错...						
						cm.worldSpouseMessage(0x0F, "排行提示  :玩家 " + cm.getChar().getName() + " 领取了PK乱斗排行榜榜首奖励！！！一周后将重置.");
					} else {
						cm.sendOk("对不起，一周只能领取一次。");
					}
				} else {
					cm.sendOk("对不起您不是PK排行榜第一\r\n只有PK排行榜榜首才能领取以下物品：#v4310015#x30 #v4250802#x12 #v4251102#x12 #v4251002#x12 #v4250902#x12 #r5万点券 5万PPMS微积分");//注意这里少了一个判断玩家背包是否满了的判断否则又无法领取了
				}
				cm.dispose();
				break;
			case 8: //人气榜单第一奖励
				var conn = cm.getConnection();
				var sql = "select name,fame,gender from characters where gm<=0 order by fame desc limit 10;";
				var pstmt = conn.prepareStatement(sql);
				var result = pstmt.executeQuery();
				result.next();
				var name = result.getString("name");
				if (cm.getChar().getName() == name) {
					if (cm.getDaysPQLog("人气王", 7) == 0) {
						cm.setPQLog("人气王", 1);
						cm.gainItem(3064311, 1);
						cm.worldSpouseMessage(0x0F, "排行提示  :玩家 " + cm.getChar().getName() + " 领取了人气王奖励！！！一周后将重置.");
					} else {
						cm.sendOk("对不起，一周只能领取一次。");
					}
				} else {
					cm.sendOk("对不起，你不是第一名。");
				}
				cm.dispose();
				break;
			case 9: //家族
				var conn = cm.getConnection();
				var sql = "select c.name as leadername, g.name from characters c, guilds g where g.leader=c.id order by g.gp desc limit 10;";
				var pstmt = conn.prepareStatement(sql);
				var list = pstmt.executeQuery();
				var text = "\t\t\t\t#e#d★ 十大家族排行 ★#k#n\r\n\r\n";
				text += "\t#e名次#n\t#e家族名称#n\t\t    #e族长#n\t\t\r\n";
				for (var i = 1; i <= 10; i++) {
					if (!list.next()) {
						break;
					}
					if (i == 1) {
						text += "#r";
					} else if (i == 2) {
						text += "#g";
					} else if (i == 3) {
						text += "#b";
					}
					text += "\t " + i + "\t\t ";

					// 填充名字空格
					text += list.getString("name");
					for (var j = 16 - list.getString("name").getBytes().length; j > 0; j--) {
						text += " ";
					}

					// 填充族长名称
					text += "\t " + list.getString("leadername");
					var leadername = list.getString("leadername");

					for (var j = 16 - list.getString("leadername").getBytes().length; j > 0; j--) {
						text += " ";
					}

					text += "\t #k";

					text += "\r\n";
				}
				list.close();
				pstmt.close();
				conn.close();
				cm.sendOkS(text, 2);
				cm.dispose();
				break;
			case 3: //土豪排名
				cm.dispose();
				cm.openNpc(9076004, "充值排名");
				break;
			case 5: //乱斗排名
				var conn = cm.getConnection();
				var sql = "select name,pvpnx from characters where gm<=0 order by pvpnx desc limit 100;";
				var pstmt = conn.prepareStatement(sql);
				var result = pstmt.executeQuery();
				var text = "\t\t\t\t#e#d★ 个人PK热力值 ★#k#n\r\n\r\n";
				text += "\t#e名次#n\t#e玩家昵称#n\t\t\t#e热力值#n\t\t #e #n\r\n";
				for (var i = 1; i <= 10; i++) {
					if (!result.next()) {
						break;
					}
					if (i == 1) {
						text += "#r";
					} else if (i == 2) {
						text += "#g";
					} else if (i == 3) {
						text += "#b";
					}
					text += "\t " + i + "\t\t ";

					// 填充名字空格
					text += result.getString("name");
					for (var j = 16 - result.getString("name").getBytes().length; j > 0; j--) {
						text += " ";
					}
					text += "\t " + result.getString("pvpnx") + "点";

					text += "\r\n";
				}
				result.close();
				pstmt.close();
				conn.close();
				cm.sendOkS(text, 2);
				cm.dispose();
				break;
			case 7: //人气
				var conn = cm.getConnection();
				var sql = "select name,fame,gender from characters where gm<=0 order by fame desc limit 10;";
				var pstmt = conn.prepareStatement(sql);
				var list = pstmt.executeQuery();
				var text = "\t\t\t\t#e#d★ 魅力人气排行 ★#k#n\r\n\r\n";
				text += "\t#e名次#n\t#e玩家昵称#n\t\t  #e人气#n\t\t  #e称号#n\r\n";
				for (var i = 1; i <= 10; i++) {
					if (!list.next()) {
						break;
					}
					if (i == 1) {
						text += "#r";
					} else if (i == 2) {
						text += "#g";
					} else if (i == 3) {
						text += "#b";
					}
					text += "\t " + i + "\t\t ";

					// 填充名字空格
					text += list.getString("name");
					for (var j = 16 - list.getString("name").getBytes().length; j > 0; j--) {
						text += " ";
					}

					// 填充人气度
					text += "\t " + list.getInt("fame");
					var famevalues = list.getInt("fame");
					var famelength = 0;
					while (famevalues > 0) {
						famevalues = Math.floor(famevalues / 10);
						famelength += 1;
					}
					for (var j = 8 - famelength; j > 0; j--) {
						text += " ";
					}

					if (i == 1) {
						if (list.getInt("gender") == 0) {
							text += "★世界偶像★#k";
						} else {
							text += "★初衷宝贝★#k";
						}
					} else if (i == 2) {
						text += "\t #k";
					} else if (i == 3) {
						text += "\t #k";
					}
					text += "\r\n";
				}
				list.close();
				pstmt.close();
				cm.sendOkS(text, 3);
				cm.dispose();
				break;
			case 11: //在线之王
				var conn = cm.getConnection();
				var sql = "select name,totalonlinetime from characters where gm<=0 order by totalonlinetime desc limit 100;";
				var pstmt = conn.prepareStatement(sql);
				var result = pstmt.executeQuery();
				var text = "\t\t\t\t#e#d★ 个人在线时间榜 ★#k#n\r\n\r\n";
				text += "\t#e名次#n\t#e玩家昵称#n\t\t\t#e在线时间#n\t\t #e #n\r\n";
				for (var i = 1; i <= 10; i++) {
					if (!result.next()) {
						break;
					}
					if (i == 1) {
						text += "#r";
					} else if (i == 2) {
						text += "#g";
					} else if (i == 3) {
						text += "#b";
					}
					text += "\t " + i + "\t\t";

					// 填充名字空格
					text += result.getString("name");
					for (var j = 16 - result.getString("name").getBytes().length; j > 0; j--) {
						text += " ";
					}
					text += "\t " + result.getString("totalonlinetime") + "(分钟)";

					text += "\r\n";
				}
				result.close();
				pstmt.close();
				conn.close();
				cm.sendOkS(text, 2);
				cm.dispose();
				break;
			case 16:
			default:
				cm.sendOk("管理员正在准备中.请期待");
				cm.dispose();
			}
		}
	}
}
